﻿<%@ Page Language="C#" MasterPageFile="~/Templates/Member.master" AutoEventWireup="true" CodeFile="Member-address-edit.aspx.cs" Inherits="Member_address_edit" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <div style="height:500px;width:100%;">
 <div style="width:100%; background-color:#F3F8FE; height:25px; color:#014D7F; padding-top:5px;">&nbsp; &nbsp;收货地址</div>
        <div>
            <div id="divContent" style="margin-left:50px; margin-top:10px; font-weight:normal; font-size:12px;">
                
                <table cellpadding="0" cellspacing="0" border="0">
                    <tr style="height:25px;"><td style="width:100px; color:#FF6600;" align="right" >新增收货地址：</td> <td>
                        电话号码、手机号选填一项,其余均为必填项</td>
                        <td style="width:260px;"></td>
                    </tr>
                    <tr style="height:25px;"><td align="right">收货人姓名：</td><td>
                        <asp:TextBox ID="txtName"    runat="server"></asp:TextBox></td>
                        <td></td>   
                    </tr>  
                    <tr style="height:25px;"><td align="right">所在地区：</td><td>
                            <select style="width:70px;" id="SelectPro" onchange="ProvinceChange(this,SelectCity);"></select>
                        <select style="width:90px;" id="SelectCity" onchange="CityChange(this,SelectArea)"></select>
                        <select style="width:90px;" id="SelectArea" ></select>
                            </td>
                        <td></td>
                    </tr>
                    <tr style="height:25px;"><td align="right">街道地址：</td><td>
                            <asp:TextBox ID="txtAddress"  runat="server" Width="429px" Height="50px" TextMode="MultiLine"></asp:TextBox></td>
                        <td> &nbsp; 不需要重复填写省/市/区</td> 
                    </tr>
                    <tr style="height:25px;"><td align="right">邮政编码：</td><td>
                        <asp:TextBox ID="txtPostCode" runat="server" MaxLength="6"></asp:TextBox></td>
                        <td></td>   
                    </tr>  
                    <tr style="height:25px;"><td align="right">电话号码：</td><td>
                        <asp:TextBox ID="txtPhone" runat="server" MaxLength="32"></asp:TextBox></td>
                        <td></td>   
                    </tr>  
                    <tr style="height:25px;"><td align="right">手机号码：</td><td>
                        <asp:TextBox ID="txtPhone1" runat="server" MaxLength="15"></asp:TextBox></td>
                        <td></td>   
                    </tr>  
                    <tr style="height:25px;"><td align="right">设为默认：</td><td>
                        <asp:CheckBox ID="cbDefault" runat="server" /></td>
                        <td></td>   
                    </tr>  
                    
                    <tr style="height:40px;"><td colspan="3" align="left" style="color:#ff0000;" >
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                        <asp:Button ID="Button1" CssClass="short-btn" OnClientClick="return CheckForm();" runat="server" Text="保 存" OnClick="Button1_Click" /> &nbsp;
                        <input type="button" value="返 回" class="short-btn" onclick="window.location.href='Member-Address.aspx';" />
                        <asp:Label ID="lblMsg" runat="server" Text=""></asp:Label>
                      </td>
                     </tr>          
                </table>
                <hr /> 
            </div>  
        </div>
    </div> 
                <div style="visibility:hidden;">
                <asp:TextBox ID="txtProvince" runat="server"></asp:TextBox>
                <asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
                <asp:TextBox ID="txtArea" runat="server"></asp:TextBox>
            </div>
<script type="text/javascript" language="javascript" src="js/Area.js"></script>
<script type="text/javascript" language="javascript">
window.onload=function()
{
    DataBing(document.getElementById("SelectPro"),ArrProvince); 
    var pro = document.getElementById("ctl00_ContentPlaceHolder1_txtProvince").value;
    var city = document.getElementById("ctl00_ContentPlaceHolder1_txtCity").value;
    var area = document.getElementById("ctl00_ContentPlaceHolder1_txtArea").value;
    var i=0;
    if(pro != "")
    {
       // document.getElementById("SelectPro").value = pro;
       // ProvinceChange(document.getElementById("ctl00_ContentPlaceHolder1_txtProvince"),document.getElementById("ctl00_ContentPlaceHolder1_txtCity"));
       var objProvince = document.getElementById("SelectPro");
       var objCity = document.getElementById("SelectCity");
       var objArea = document.getElementById("SelectArea");
       var opts = objProvince.options;
       for(i=0;i<opts.length;i++)
       {
            if( opts[i].text == pro)
            {
                objProvince.value = opts[i].value;
                ProvinceChange(objProvince,objCity);
                break;
            }
       }
       
       if(city != "")
       {
           var opts = objCity.options;
           for(i=0;i<opts.length;i++)
           {
                if( opts[i].text == city)
                {
                    objCity.value = opts[i].value;
                    CityChange(objCity,objArea);
                    break;
                }
           }
           if(area != "")
           {
               var opts = objArea.options;
               for(i=0;i<opts.length;i++)
               {
                    if( opts[i].text == area)
                    {
                        objArea.value = opts[i].value; 
                        break;
                    }
               }
           }
       }
    }
}
function CheckForm()
{
    var strName =trim(document.getElementById("ctl00_ContentPlaceHolder1_txtName").value);
    if(strName=="")
    {
        alert("收货人姓名不能为空！");
        document.getElementById("ctl00_ContentPlaceHolder1_txtName").focus();
        return false;
    }
    var strProvince = document.getElementById("SelectPro").value;;
    if(strProvince == "")
    {
        alert("请选择一个省份！");
        document.getElementById("SelectPro").focus();
        return false;
    }
    var strCity = document.getElementById("SelectCity").value;;
    if(strCity == "")
    {
        alert("请选择一个城市！");
        document.getElementById("SelectCity").focus();
        return false;
    }
    var strArea = document.getElementById("SelectArea").value;;
//    if(strArea == "")
//    {
//        alert("请选择一个县区！");
//        document.getElementById("SelectArea").focus();
//        return false;
//    }
    
    var strAdd = trim(document.getElementById("ctl00_ContentPlaceHolder1_txtAddress").value);
    if(strAdd == "")
    {
        alert("街道地址不能为空 ！");
        document.getElementById("ctl00_ContentPlaceHolder1_txtAddress").focus();
        return false;
    }
    var strPhone =  trim(document.getElementById("ctl00_ContentPlaceHolder1_txtPhone").value);
    var strPhone1 = trim(document.getElementById("ctl00_ContentPlaceHolder1_txtPhone1").value);
    if(strPhone=="" && strPhone1=="")
    {
        alert("电话或者手机必须要填写一项！");
        document.getElementById("ctl00_ContentPlaceHolder1_txtPhone").focus();
        return false;
    }
    
     var objPro =  document.getElementById("SelectPro");
            var objCity = document.getElementById("SelectCity");
            var objArea = document.getElementById("SelectArea");
            document.getElementById("ctl00_ContentPlaceHolder1_txtProvince").value =objPro.options[objPro.selectedIndex].text;
            document.getElementById("ctl00_ContentPlaceHolder1_txtCity").value = objCity.options[objCity.selectedIndex].text;
            document.getElementById("ctl00_ContentPlaceHolder1_txtArea").value = objArea.options[objArea.selectedIndex].text;
    return true;
}
</script>
</asp:Content>

